package com.dys.testproject;

/**
 * @className: com.dys.testproject.BasePizzeria
 * @description: 披萨父类
 * @author: pine cone
 * @version: v1.0.0
 * @createTime: 2024/07/22 下午10:45
 */
public class BasePizzeria {
    private String name;
    private int size;
    private double price;

    public BasePizzeria() {
    }

    public BasePizzeria(String name, int size, double price) {
        this.setName(name);
        this.setSize(size);
        this.setPrice(price);
    }

    /**
     * 展示披萨信息
     *
     * @return 披萨信息
     */
    public String show() {
        return "名称: " + this.name + "\n价格: " + this.price + "元\n大小: " + this.size + "寸";
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        if (name == null || "".equals(name)) {
            throw new RuntimeException("披萨名词必填");
        }
        this.name = name;
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        if (size < 0) {
            throw new RuntimeException("大小不能为负");
        }
        this.size = size;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        if (price < 0.0) {
            throw new RuntimeException("价格不能为负");
        }
        this.price = price;
    }
}
